YUI.add('projectpathview', function (Y) {
	Y.namespace('AppView');
	Y.AppView.ProjectPathView = Y.Base.create('projectPathView', Y.View, [], {
	    // This is where we attach DOM events for the view. The `events` object is a
	    // mapping of selectors to an object containing one or more events to attach
	    // to the node(s) matching each selector.
	    
	    container:Y.one('#project-path'),
	
	    // The `template` property is a convenience property for holding a
	    // template for this view. In this case, we'll use it to store the
	    // contents of the #project-stats-template element, which will serve as the
	    // template for the statistics displayed at the bottom of the list.
	    template: '<a href="#item={uuid}&shared={shared}" class="path-link">{title}</a>',
	    
	    ctemplate : '<a href="#" class="path-link" id="path-link-home">Home</a> > ',
	    
	    events: {//可能是hide的关系。
	    	'.path-link':{click:'itemClick'},
	    	'#path-link-home':{click:'itemClick'}
	    },
	
	    // The initializer runs when a ProjectAppView instance is created, and gives
	    // us an opportunity to set up the view.
	    initializer: function () {
	        // Create a new ProjectList instance to hold the Project items.
	    	var tthis = this;
	    	Y.on('history:change', function (e) {
	    		  var changed = e.changed,
	    		      removed = e.removed;
	    		  if (changed.item) {
	    			  tthis.buildPath(changed.item.newVal);
	    		  } else if (removed.item) {
	    			  tthis.container.hide(true);
	    		  }
	    	});
	    },
	
	    render: function () {
	    	var history = new Y.HistoryHash();
	    	this.buildPath(history.get('item'));
	        return this;
	    },
	    
	    itemClick : function(e){
	    	alert(e);
	    	e.preventDefault();
	    },
	    
	    buildPath: function(mid){
	    	if(mid){
	    		var ra = [];
	    		var r = Y.totalDataHash[mid];
	    		while(r){
	    			ra.push(r);
	    			r = Y.totalDataHash[r.getValue('dp')];
	    		}
	    		if(ra.length > 0){
	    			var c = '';
	    			while(ra.length > 0){
	    				if(ra.length == 1){
	    					c += ra.pop().getValue('title');
	    				}else{
	    					c += Y.Lang.sub(this.template,ra.pop().get('data')) + ' > ';
	    				}
	    				
	    			}
	    			if(Y.sharedMode){
	    				c = Y.Lang.sub(c,{shared:'true'});
	    				this.container.setContent(c);
	    			}else{
	    				c = Y.Lang.sub(c,{shared:'false'});
	    				this.container.setContent(this.ctemplate + c);
	    			}
	    			
	    			this.container.show(true);
	    		}
	    	}
	    }
	}, {
	    ATTRS: {
	    }
	});
},'0.0.1',{requires:['node','base','event','view','model', 'model-list','transition']});